define(["jquery","text!modules/delivery/delivery.html","modules/header/header","modules/footer/footer","css!modules/delivery/delivery.css"],function($,html,header,footer){
	function render(){
		$("body").empty();
		footer.render();
		header.render();
		$("body").append(html);	
		// 最低价格
		$(".delivery_classify li").on('touchstart',function(){
			var index=$(this).index();
			if($(".shadow").eq(index).css("display")=="none"){
				$(".shadow").css("display","none");
				$(".shadow").eq(index).css("display","block");
			}else{
				$(".shadow").eq(index).css("display","none");
			}	
		})
		//或获取数据
		var arrData=["热销榜","天天特价","优选水果","牛奶面包"];
		function Data(classify){
			$.ajax({
			url:"http://www.vrserver.applinzi.com/aixianfeng/apicategory.php",
			type:"get",
			data:{
				category:classify
			},
			success:function data(res){
				var data=$.parseJSON(res);
				createCommodity(data);
			}
			});
		}
		Data(arrData[0]);
		//创建商品列表
		function createCommodity(data){
			var data=data.data;
			$(".delivery_commodity").empty();
			for(var i=0;i<data.length;i++){
				var img=$("<div class="+"delivery_liImg"+"></div>").css("backgroundImage","url("+data[i].img+")");
				var li=$("<li><div class="+"delivery_particular"+"><p class="+"delivery_product-name"+">"+data[i].name+"</p><p class="+"delivery_productP1"+"><span class="+"delivery_choiceness"+">精选</span><span class="+"give"+">买一送一</span></p><p class="+"weight"+">"+data[i].specifics+"</p><p class="+"productP2"+"><span class="+"delivery_Nprice"+">"+data[i].price+"</span><span class="+"delivery_Oprice"+">"+data[i].market_price+"</span></p><div class="+"delivery_btn"+"><span class='add delivery_Gbth'></span><span class='delivery_Number'>1</span><span class='subtract delivery_Gbth'></span></div></div></li>").prepend(img);
				$(".delivery_commodity").append(li);
			}
		}
		// 点击侧栏
			$(".delivery_leftNav li").on('touchstart',function(){
				var index=$(this).index();				
				$(".delivery_leftNav li p").removeAttr("class","delivery_change");
				$(".delivery_leftNav li p").eq(index).attr("class","delivery_change");
				index>3? index=3:index;
				Data(arrData[index])
				
			})
//页脚
	for(var i=0;i<5;i++){
		$(".footer .top").eq(i).css("backgroundImage","url(img/footer"+i+".png)");
	}	
	$(".footer .top").eq(1).css("backgroundImage","url(img/f"+1+".png)");

	$(".header_header .header_scan").css("visibility","hidden");		
	}
	return{
		render:render
	}
})